<?php
if(define(__FILE__,true)) {
	
	final class Rebel_Loader_Plugins_Auth {
		
		public static function execute($node) {
			
			if($auth = $node->getAttribute('auth')) {
				if(
					($authclass = $node->getAttribute('authclass')) && 
					($authmethod = $node->getAttribute('authmethod'))
				)
				{
					$m = new ReflectionMethod($authclass,$authmethod);
					if($m->isStatic()) {
						$m->invoke(null);
					} else {
						$o = new ReflectionClass($authclass);
						$m->invoke($o->newInstance());
					}
				} else {
					
					throw new Rebel_Loader_Plugins_Auth_Exception(Rebel_Loader_Plugins_Auth_Exception::AUTH_CLASS_OR_METHOD_MISSING);
					
				}
			}
		}//:-
		
	}///:-
	
	class Rebel_Loader_Plugins_Auth_Exception {
		
		const AUTH_CLASS_OR_METHOD_MISSING = 1;
		
		private static $messages = array(
			self::AUTH_CLASS_OR_METHOD_MISSING => 'MISSING XMAP ATTRIBUTES authclass and authmethod %s'
		);
		
		public function __construct($code=null,$paramName = null) {
			$message = isset(self::$messages[$code]) ? sprintf(self::$messages[$code],$paramName) : 'Unknown Exception';
			throw new Exception($message,$code);
		}//:-
		
	}///:-
}
?>